/*
 * Copyright (c) 2020 Nanjing Xiaoxiongpai Intelligent Technology Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <stdio.h>
#include <unistd.h>

#include "cmsis_os2.h"
#include "iot_gpio.h"
#include "iot_gpio_ex.h"
#include "ohos_init.h"
#include "E53_SC2.h"


#define MPU6050_INT 14

int INT_flg = 0;

/**
 * @brief Callback for F1 key
 *
 */
static void DMP_INT(char *arg)
{
    (void)arg;
    INT_flg=1;
    //mpu_dmp_get_data(&Pitch,&Roll,&Yaw);//获取DMP数据要快点，否则数据堵塞导致数据异常
    //printf("pitch=%f, Roll=%f, Yaw=%f\r\n",Pitch,Roll,Yaw);
}

/**
 * @brief Main Entry of the Button Example
 *
 */
void MPU6050_INT_Entry(void)
{
    // init gpio of F1 key and set it as the falling edge to trigger interrupt
    IoTGpioInit(MPU6050_INT);
    IoTGpioSetFunc(MPU6050_INT, IOT_GPIO_FUNC_GPIO_14_GPIO);
    IoTGpioSetDir(MPU6050_INT, IOT_GPIO_DIR_IN);
    IoTGpioSetPull(MPU6050_INT, IOT_GPIO_PULL_UP);
    IoTGpioRegisterIsrFunc(MPU6050_INT, IOT_INT_TYPE_EDGE, IOT_GPIO_EDGE_FALL_LEVEL_LOW, DMP_INT, NULL);

}

//APP_FEATURE_INIT(MPU6050_INT_Entry);